﻿using Abp.Application.Services;
using Abp.Domain.Repositories;
using Abp.Linq.Extensions;
using AbpVueDemo.DepartDemo.Dto;
using AbpVueDemo.DeperManager;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpVueDemo.DepartDemo
{
    public class DepartService : AsyncCrudAppService<Deparent, DepartInputDto,
       int, PageDepartDto, DepartCreateDto, DepartUpdateDto>, IDepartService
    {
        public DepartService(
      IRepository<Deparent, int> repository) : base(repository)
        {

        }

        protected override IQueryable<Deparent> CreateFilteredQuery(PageDepartDto input)
        {
            return base.CreateFilteredQuery(input)
                .WhereIf(!string.IsNullOrEmpty(input.depart_name), c => c.depart_name.Contains(input.depart_name))
                .WhereIf(!string.IsNullOrEmpty(input.zhiwei_name), c => c.zhiwei_name.Contains(input.zhiwei_name))
                .WhereIf(!string.IsNullOrEmpty(input.yg_name), c => c.yg_name.Contains(input.yg_name))
                .WhereIf(input.daogangtime != null, c => c.daogangtime == (input.daogangtime))
                .WhereIf(!string.IsNullOrEmpty(input.shenpizt), c => c.shenpizt.Contains(input.shenpizt))
                .WhereIf(input.hetongtime != null, c => c.hetongtime == (input.hetongtime))
                .WhereIf(input.ruzhitime != null, c => c.ruzhitime == (input.ruzhitime))
                .WhereIf(input.latetime != null, c => c.latetime == (input.latetime))
                .WhereIf(input.shenqingtime != null, c => c.shenqingtime == (input.shenqingtime));
        }
    }
}
